from ultralytics import YOLO
model = YOLO("runs/detect/train/weights/best.pt")
model.export(format='onnx', dynamic=True, opset=12)  # 动态批次/尺寸